package ua.pp.bizon.yandex.uploader.atom;

import java.util.Map;
import java.util.TreeMap;

public class AppService {

	public static final String SERVICE_URL = "http://api-fotki.yandex.ru/api/me/";

	private String title;
	private Map<String, AppLink> links;

	public void setTitle(String title) {
		this.title = title;
	}

	public String getTitle() {
		return title;
	}

	protected Map<String, AppLink> getLinks() {
		if (links == null) {
			links = new TreeMap<String, AppLink>();
		}
		return links;
	}

	@Override
	public String toString() {
		return "AppService [title=" + title + ", links=" + links + "]";
	}

	public AlbumsList getAlbumsList() {
		if (albumsList == null) {
			albumsList = createAlbumsList();
		}
		return albumsList;
	}

	protected AlbumsList createAlbumsList() {
		return AlbumsListFactory.get(getAlbumsLink());
	}

	public AppLink getAlbumsLink() {
		return getLinks().get("album-list");
	}

	private AlbumsList albumsList;
	private PhotosList photosList;

	public PhotosList getPhotosList() {
		if (photosList == null) {
			photosList = createPhotosList();
		}
		return photosList;
	}

	protected PhotosList createPhotosList() {
		return PhotosListFactory.create(getLinks().get("photo-list"));
	}
}
